/**
 *  게시판 함수
 */

var url = "MyHome.jsp?inc_content=./board_mybatis/";
function getId(id){return document.getElementById(id)}

//--------------------------------------------
//스크립트 초기화
//--------------------------------------------
function init(){
	
	if(getId("btnlist") != null) {
		getId("btnlist").onclick = function() {
			location.href = url + "list.jsp";
		}
	}
	
	if(getId("btnwrite") != null){
		getId('btnwrite').onclick=function(){
			location.href= url + "register.jsp";
		}
	}
	if(getId("btninsert") != null){
		getId('btninsert').onclick=function(){
			frm.action = url + "register_result.jsp";
			frm.submit();
		}
	}
	/*if(getId("btnmodify") != null){
		getId("btnmodify").onclick=function(){
			location.href = url + "modify.jsp"
		}
	}*/
	if(getId("btn_rep_insert") != null){
		getId("btn_rep_insert").onclick=function(){
			community_frm.action = url + "rep_register_result.jsp";
			community_frm.submit();
		}
	}
	if(getId("btnModifyResult") != null){
		getId("btnModifyResult").onclick=function(){
			community_form.action = url + 'modify_result.jsp';
			community_form.submit();
		}
	}
	if(getId("btnfind") != null){
		getId("btnfind").onclick=function(){
			community_form.action = url + "list.jsp";
			community_form.submit();
		}
	} 
}	
//--------------------------------------------
//게시판 종류 선택
//--------------------------------------------
function goBoard(part){
	location.href = url + "list.jsp&nowPage=1&part=" + part;
}

//--------------------------------------------
//상세정보
//--------------------------------------------
function view(serial){
	location.href = url + "view.jsp&serial=" + serial;
}
//--------------------------------------------
//수정
//--------------------------------------------
function modi(serial){
	location.href = url + "modify.jsp&serial=" + serial;
}
//--------------------------------------------
//답글
//--------------------------------------------
function rep(serial, grp, deep){
	location.href = url + "rep_register.jsp&serial=" + serial + "&grp=" + grp + "&deep=" + deep;
}
//--------------------------------------------
//삭제
//--------------------------------------------
function del(serial,filename){
	var f = confirm("정말 삭제하시겠습니까 ?");
	if(f){
		location.href = url + "delete_result.jsp&serial=" + serial + "&filename=" + filename;
	}
	
}
//--------------------------------------------
//파일삭제
//--------------------------------------------
function fileDel(fileDelFlag, serial){
	var f = confirm("첨부 파일을 정말 삭제하시겠습니까???");
	if(f){
		location.href= url + "modify.jsp&fileDelFlag=" + fileDelFlag + "&serial=" + serial;
	}else{
		alert("삭제가 취소되었습니다.");
	}
}

// 파일 다운로드 스크립터
// 새창을 열어 첨부파일을 무조건 다운로드하도록 조치
function fileDownload(filename){
	url = './board_mybatis/filedownload.jsp?filename='+filename;
	win = window.open(url, "win", "");
}

function goPage(page){

	var ff = document.community_form;
	ff.nowPage.value = page;
	ff.action = url + "list.jsp";
	ff.submit();
}
